//
//  JXPCatalogueTableViewController.m
//  模拟-百思不得姐
//
//  Created by ColinJ on 16/8/8.
//  Copyright © 2016年 colin. All rights reserved.
//

#import "JXPCatalogueTableViewController.h"
#import "JXPCatalogueTableViewCell.h"
#import "JXPVideoTableViewController.h"
#import "JXPRecommendTableViewController.h"
#import "UIViewController+MMDrawerController.h"
@interface JXPCatalogueTableViewController ()

@property (nonatomic) NSArray *catalogueArray;
@end

@implementation JXPCatalogueTableViewController

- (NSArray *)catalogueArray {
    if (!_catalogueArray) {
        _catalogueArray = [[NSArray alloc]init];
        _catalogueArray = @[@"推荐",@"视频"];
    }
    return  _catalogueArray;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"不可以";
    [self.tableView registerNib:[UINib nibWithNibName:@"JXPCatalogueTableViewCell" bundle:nil] forCellReuseIdentifier:@"menuCell"];
    self.tableView.backgroundColor = [UIColor cyanColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"menuCell" forIndexPath:indexPath];
    cell.textLabel.text = self.catalogueArray[indexPath.row];
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    JXPRecommendTableViewController *recommendVC = [[JXPRecommendTableViewController alloc] init];
    JXPVideoTableViewController *videoVC = [[JXPVideoTableViewController alloc] init];

    NSArray *array = @[recommendVC, videoVC];
    
    //拿到我们的LitterLCenterViewController，让它去push
    UINavigationController* nav = (UINavigationController*)self.mm_drawerController.centerViewController;
    [nav pushViewController:array[indexPath.row] animated:NO];
    
    //当我们push成功之后，关闭我们的抽屉
    [self.mm_drawerController closeDrawerAnimated:YES completion:^(BOOL finished) {
        //设置打开抽屉模式为MMOpenDrawerGestureModeNone，也就是没有任何效果。
        [self.mm_drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    }];
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
